<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">
        <span aria-hidden="true">×</span>
        <span class="sr-only">Close</span>
    </button>
    <h4 class="modal-title">创建备份</h4>
</div>
<div id="main-body" xmlns:th=http://www.thymeleaf.org>
    <div class="modal-body">
        <div class="row">
            <div class="col-lg-10">
                <form method="post" th:action="@{db/__${dbname}__}" th:object="${backupInfoBean}"
                      class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">备份名称</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" th:field="*{dvname}" th:placeholder="${dbname}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">备份备注</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control" th:field="*{dvinfo}" th:placeholder="用户没有填写">
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                </form>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
        </button>
        <button type="submit" class="btn btn-primary" th:onclick="'javascript:createBackup()'">
            创建
        </button>
    </div>
</div>

<script th:inline="javascript">
/*<![CDATA[*/
var dbname = [[${dbname}]];
$(document).ready(function () {
        $('.form-horizontal').ajaxForm();
//        $('#main-body').slimScroll({
//            height: 437,
//            railOpacity: 0.8
//        });
//        $('.i-checks').iCheck({
//            checkboxClass: 'icheckbox_square-green',
//            radioClass: 'iradio_square-green',
//        });
});

    function createBackup() {
        var options = {
            beforeSubmit : function(){
//                $("<div class=\"loadingWrap\"></div>").appendTo("#main-body");
                showMLoading();
            },
//          提交后的回调函数
            success: function (data,statusText) {
//                $(".loadingWrap").remove();
                hideMLoading();
                if(data.flag) {
                    modalHide(true);
                    getPage(dbname);
                    showMessage(1,'备份成功！',2);
                }else {
                    showMessage(3,data.msg,10);
                }
            },
//          url : url,    //默认是form的action，如果申明，则会覆盖
            type: "POST",    // 默认值是form的method("GET" or "POST")，如果声明，则会覆盖
            dataType: "json",    // html（默认）、xml、script、json接受服务器端返回的类型
            clearForm: true,    // 成功提交后，清除所有表单元素的值
            resetForm: true,    // 成功提交后，重置所有表单元素的值
            timeout: 3000000    // 限制请求的时间，当请求大于3秒后，跳出请求
        };
        $('.form-horizontal').ajaxSubmit(options);
        return false;
    }
/*]]>*/
</script>

